package com.xnxy.design.util;

import java.util.HashMap;
import java.util.Map;

/**
 * 封装返回数据类型工具类
 * @author puzengcheng
 * @date 2018/10/23
 */
public class ControllerReturn {

    /**
     * 返回map工具方法
     *
     * @param msg
     * @param data
     * @return Map
     */
    public static Map<String, Object> success(Object result, String msg, Object data) {
        HashMap<String,Object> map = new HashMap();
        map.put("result", result);
        map.put("msg", msg);
        if (data != null) {
            map.put("data", data);
        }
        return map;
    }

    /**
     * 返回map工具方法
     *
     * @param msg
     * @return Map
     */
    public static Map<String, Object> success(Object result, String msg) {
        Map<String, Object> map = new HashMap();
        map.put("result", result);
        map.put("msg", msg);
        return map;
    }
}
